import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";

import router from "@/routers/index";
import pinia from "@/stores/index";
import { i18n } from "@/locales/index";

import ElementPlus from "element-plus";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

import "uno.css";
import "element-plus/theme-chalk/dark/css-vars.css";
import "./styles/theme.scss"; // 引入主题样式

// svg图标
import "virtual:svg-icons-register";
import "./assets/iconfont/iconfont.css";

import { safeT } from "@/locales/index";
import directives from "./directives";

import websocketPlugin from "@/plugins/websocket";

const app = createApp(App);

app.config.globalProperties.$safeT = safeT;

// 全局注册element图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

app
  .use(pinia)
  .use(router)
  .use(ElementPlus)
  .use(i18n)
  .use(directives)
  .use(websocketPlugin, {
    url: "wss://xc.redxing.cn/ws", // 替换为你的 WebSocket 服务器地址
    heartbeatInterval: 10000, // 10秒心跳
    reconnectInterval: 5000, // 5秒后重连
    maxReconnectAttempts: 5 // 最多重连5次
  })
  .mount("#app");
